IdeaBlade.EntityModel.Compat Assembly > IdeaBlade.EntityModel Namespace > Coroutine Class > StartParallel Method : StartParallel(Func<IEnumerable<INotifyCompleted>>,Action<CoroutineOperation>) Method |
'Declaration
Public Overloads Shared Function StartParallel( _ ByVal coroutine As Func(Of IEnumerable(Of INotifyCompleted)), _ Optional ByVal completedHandler As Action(Of CoroutineOperation) _ ) As CoroutineOperation
'Usage
Dim coroutine As Func(Of IEnumerable(Of INotifyCompleted)) Dim completedHandler As Action(Of CoroutineOperation) Dim value As CoroutineOperation value = Coroutine.StartParallel(coroutine, completedHandler)
public static CoroutineOperation StartParallel( Func<IEnumerable<INotifyCompleted>> coroutine, Action<CoroutineOperation> completedHandler )
See the second example below for how to pass arguments into the iterator.
public void CoroutineSampleParallel() { // Start some parallel async operations. var op = Coroutine.StartParallel(SampleActions); // Listen for completion. op.Completed += (s, e) => { MessageBox.Show(e.Notifications.Count.ToString() + " operations completed"); // You can loop thru notifications for results from each operation. }; } // A block of asynchronous actions to be performed in parallel. private IEnumerable<INotifyCompleted> SampleActions() { // Start a query for all customers in specified country. yield return _entityManager.Customers.Where(c => c.Country == "UK").ExecuteAsync(); // Start another query for all employees. This will run in parallel. yield return _entityManager.Employees.ExecuteAsync(); } /***************************************************************************************/ // Sample 2 - passing arguments to an iterator public void CoroutineSampleParallel2() { // Start some parallel async operations. var op = Coroutine.StartParallel(() => SampleActions2("UK")); // Listen for completion. op.Completed += (s, e) => { MessageBox.Show(e.Notifications.Count.ToString() + " operations completed"); // You can loop thru notifications for results from each operation. }; } // A block of asynchronous actions to be performed in parallel. private IEnumerable<INotifyCompleted> SampleActions2(string country) { // Start a query for all customers in specified country. yield return _em1.Customers.Where(c => c.Country == country).ExecuteAsync(); // Start another query for all employeesin specified country. This will run in parallel. yield return _em1.Employees.Where(e=> e.Country == country).ExecuteAsync(); }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2